package cn.edu.buaa.cnsatm.traffic_big_data_server.division.dao;

import cn.edu.buaa.cnsatm.traffic_big_data_server.util.JDBCUtil;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.TreeMap;

/**
 * @name = LX
 * @classname = TheaterDivisionDAO
 * @description = 战区区划相应DAO
 * @date = 2019/10/23
 */
public class TheaterDivisionDAO {
    public static ResultSet getProvinceByLonAndLa(Double longitude, Double latitude){
        /**
         * @author: LX
         * @methodName: getProvinceByLonAndLa
         * @description: 获取经纬度所在省
         * @data: 2019-10-23
         **/
        String sql = "SELECT \"name\",theater_division FROM \"province_region\" WHERE ST_Contains(st_geomfromtext(st_astext(geom)),st_makepoint(" + longitude + "," + latitude + "))";
        //System.out.println(sql);
        Statement stmt = null;
        ResultSet resultSet = null;
        try {
            stmt = JDBCUtil.databaseConnecttion.createStatement();//创建数据库查询实体
            resultSet= stmt.executeQuery(sql);//执行Sql查询语句
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return resultSet;
    }

}
